package day0221;

import java.util.Arrays;

public class Test7 {
    public static void main(String[] args) {
        int[] arr={0,0,0,0,0,0};
        for (int i = 0; i < arr.length; i++) {
            arr[i]=(int)(Math.random()*100);
        }
        System.out.println(Arrays.toString(arr));

        for(int j=1; j< arr.length; j++) {
            for (int i = 0; i < arr.length - j; i++) {
                if (arr[i] > arr[i + 1]) {
                    int t = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = t;
                }
            }
        }
        System.out.println(Arrays.toString(arr));












        /*


        System.out.println(arr[5]);
        //for(){}//5//将最大值放到最后













        //将排在第二位的数放到倒数第二位
        for (int i = 0; i < 6-2; i++) {
            if(arr[i] > arr[i+1]){
                int t=arr[i];
                arr[i]=arr[i+1];
                arr[i+1]=t;
            }
        }
        System.out.println(arr[4]);


        //将排在第二位的数放到倒数第二位
        for (int i = 0; i < 6-3; i++) {
            if(arr[i] > arr[i+1]){
                int t=arr[i];
                arr[i]=arr[i+1];
                arr[i+1]=t;
            }
        }
        System.out.println(arr[3]);

        //将排在第二位的数放到倒数第二位
        for (int i = 0; i < 6-4; i++) {
            if(arr[i] > arr[i+1]){
                int t=arr[i];
                arr[i]=arr[i+1];
                arr[i+1]=t;
            }
        }
        System.out.println(arr[3]);



        //将排在第二位的数放到倒数第二位
        for (int i = 0; i < 6-5; i++) {
            if(arr[i] > arr[i+1]){
                int t=arr[i];
                arr[i]=arr[i+1];
                arr[i+1]=t;
            }
        }
        System.out.println(arr[3]);*/
    }
}
